package listbyorder.access001_100.test17;

import java.util.LinkedList;
import java.util.List;

/**
 * 使用队列实现
 *
 * @author code_yc
 * @version 1.0
 * @date 2020/5/28 10:10
 */
public class Solution2 {

    public List<String> letterCombinations(String digits) {
        LinkedList<String> ans = new LinkedList<>();
        if (digits == null || digits.equals("")) return ans;
        ans.add("");
        String[] dic = {"", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
        for (int i = 0; i < digits.length(); i++) {
            String cur_str = dic[digits.charAt(i) - '0'];
            while (ans.peek().length() == i) {
                String t = ans.remove();
                for (char c : cur_str.toCharArray()) {
                    ans.add(t + c);
                }
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        String s = "";
        System.out.println(s.length());
    }
}
